package com.xinz.protocal.server;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class NativeMethod {

	/**
	 * 请求头
	 */
	Object requestHeader;
	
	/**
	 * 本地的方法
	 */
	Method method;
	
	/**
	 * 请求方法参数
	 */
	Object[] args;
	
	/**
	 * 请求自定义参数
	 */
	Map<String, Object> atts = new HashMap<String, Object>();
	
	public NativeMethod(Method method, Object[] args, Object requestHeader) {
		super();
		this.method = method;
		this.args = args;
		this.requestHeader = requestHeader;
	}
	
	public Object invoke(Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		return method.invoke(obj, args);
	}
	
	public Object getRequestHeader() {
		return requestHeader;
	}
	
	public Method getMethod() {
		return method;
	}
	
	public Object[] getArgs() {
		return args;
	}
	
	public Object getAttribute(String key) {
		return atts.get(key);
	}
	
	public void setAttribute(String key, Object value) {
		atts.put(key, value);
	}
}
